#!/usr/bin/env python
# encoding: utf-8
import pika

credentials = pika.PlainCredentials("guest", "guest")
conn_params = pika.ConnectionParameters("localhost",credentials=credentials)
conn_broker = pika.BlockingConnection(conn_params)
channel = conn_broker.channel()

channel.exchange_declare(exchange="exchange11", 
                         exchange_type="direct",
                         passive=False,
                         durable=False,
                         auto_delete=False)

channel.queue_declare(queue="ttl_long-queue",arguments={"x-expires":60000,"x-max-length":1000}) #过期时间单位ms

channel.queue_bind(queue="ttl_long-queue", 
                   exchange="exchange11",
                   routing_key="hola")

for n in range(1500):
   channel.basic_publish(body="message",
                      exchange="exchange11",
                      routing_key="hola")
